<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');

$section_id = mysql_real_escape_string(strip_tags($_POST['sec_id']));
$csm_id = mysql_real_escape_string(strip_tags($_POST['csm_id']));
$course_id = mysql_real_escape_string(strip_tags($_POST['cid']));
$subject_id = mysql_real_escape_string(strip_tags($_POST['sid']));

$get_subject_data = mysql_query("SELECT * FROM course_subjects WHERE id = $subject_id");
$subject_name = mysql_result($get_subject_data,0,'subject_title');
$abbreviation = mysql_result($get_subject_data,0,'abbreviation');

$get_course_data = mysql_query("SELECT * FROM courses WHERE id = $course_id");
$course_number = mysql_result($get_course_data,0,'course_number');
$course_name = mysql_result($get_course_data,0,'title');

$get_section_data = mysql_query("SELECT * FROM course_sections WHERE id = $section_id");
$section_number = mysql_result($get_section_data,0,'section_number');

echo "<h1>Delete Section from $abbreviation $course_number</h1>";

$csm_query = "DELETE FROM course_section_mapping WHERE id='$csm_id'";
$csm_result = mysql_query($csm_query);

$sec_query = "DELETE FROM course_sections WHERE id='$section_id'";
$sec_result = mysql_query($sec_query);

if ($csm_result && $sec_result)
{
	echo "Section <b>$section_number</b> has been successfully deleted!";
	echo "<br />";
}
else
{
	echo "Section <b>$section_number</b> was NOT able to be successfully deleted!";
	echo "<br />";
}

//close
mysql_close();

echo "<p>";
	echo "<a href='index.php?sid=$subject_id&id=$course_id'>&lt;&lt; Back to Sections Portal</a><br />";
echo "</p>";

?>

<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>